//
//  ApiManager.m
//  CarDeal_IOS
//
//  Created by 孙可 on 2018/8/20.
//  Copyright © 2018年 sunke. All rights reserved.
//

#import "ApiManager.h"
#import "Login.h"

@implementation ApiManager

+ (instancetype)sharedManager {
    static ApiManager *shared_manager = nil;
    static dispatch_once_t pred;
    dispatch_once(&pred, ^{
        shared_manager = [[self alloc] init];
    });
    return shared_manager;
}

-(void)getSlide:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    NSString * url  = [NSString stringWithFormat:@"%@/%@/%@",GET_SLIDE,[params objectForKey:@"type"],[params objectForKey:@"position"]];
    [[ApiCilent sharedClient] patchData:url withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}


-(void)getMyShopList:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    [[ApiCilent sharedClient] postJsonData:GET_MY_SHOP withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}


-(void)getRecommendShopList:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    [[ApiCilent sharedClient] postJsonData:GET_RECOMMDED_SHOP withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}

-(void)getShopDetails:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    NSString * url  = [NSString stringWithFormat:@"%@/%@",GET_SHOP_DETAIS,[params objectForKey:@"id"]];
    [[ApiCilent sharedClient] patchData:url withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}


-(void)getShopComments:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    [[ApiCilent sharedClient] postJsonData:GET_CUSTOMER_COMMENT withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}


-(void)addShopToFav:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    [[ApiCilent sharedClient] postJsonData:ADD_SHOP_TO_FAV withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}

-(void)getShopOrderTime:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    [[ApiCilent sharedClient] postJsonData:GET_SHOP_ORDERTIME withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}

-(void)getCarList:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    NSString * url  = [NSString stringWithFormat:@"%@/%@",GET_CAR_LIST,[params objectForKey:@"id"]];
    [[ApiCilent sharedClient] patchData:url withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}

-(void)addConvention:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    [[ApiCilent sharedClient] postJsonData:ADD_CONVENTION withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}

-(void)getInfoByPlateNumber:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    NSString * url  = [NSString stringWithFormat:@"%@/%@",GET_INFO_BY_PLATENUMBER,[params objectForKey:@"plateNumber"]];
    [[ApiCilent sharedClient] patchData:url withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}

-(void)getShopWashPrice:(NSDictionary *)params andBlock:(void (^)(id, NSError *))block{
    [[ApiCilent sharedClient] postJsonData:GET_SHOP_WASH_PRICE withParams:params andBlock:^(id data, NSError *error) {
        block(data,nil);
    }];
}

@end
